<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/order.css">
    <link rel="stylesheet" type="text/css" href="/h5/css/all.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
    <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
</head>
<body>

<!----------订单详情页面---------->
<div id="orderShowPage">
    <div id="orderShowTitle">
        <span class="name"></span>详情
        <img src="../images/return.png" id="orderRtn" onclick="history.go(-1)">
    </div>
    <div style="height:1.066667rem"></div>
    <div id="orderShowSample">
        <div class="orderShowSampleImg">
            <div class="bigImg">
                <img >
            </div>
            <div class="smallImg">
                <ul>
                    
                </ul>
            </div>
        </div>
        <div class="orderShowSampleSubmit">
            <div class="first">
                <span class="status"></span>
                <span class="none">已有<span class="grapcount">0</span>家工厂参与抢单</span>
            </div>
            <div class="apply">
                <div  id="orderShowApply" style="display: none">马上抢单</div>
                <div id="orderJingxuan" style="display: none">查看竞选方</div>
            </div>
        </div>
    </div>
    <div id="orderShowAttr">
        <ul class="list">
            <li>
                <div>价钱</div>
                <div class="money"></div>
            </li>
            <!--li>
                <div>要求等级</div>
                <div class="level"></div>
            </li-->
            <li class="bondli">
               <div>需要保证金</div>
               <div class="bond"></div>
           </li>
            <li class="order_isrob" style="display: none">
                <div>普通订单</div>
                <div class="bond">免保证金</div>
            </li>

            <li>
                <div>生产数量</div>
                <div class="num"></div>
            </li>
            <li>
                <div>交货时间</div>
                <div class="period"></div>
            </li>
            <li style="display: none">
                <div>适用场合</div>
                <div class="scence"></div>
            </li>
            <li>
                <div>产品颜色</div>
                <div class="color">
                </div>
            </li>
            <li>
                <div>产品材质</div>
                <div class="material"></div>
            </li>
        </ul>
    </div>
    <div id="orderShowDetail">
        <p class="detail"></p>
        <p>
            <!-- <img src="../../uploads/20190227/protest.png"> -->
        </p>
    </div>
</div>
<!----------订单详情页面---------->

<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../js/getPageId.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script type="text/javascript" src="../js/orderPageChange.js"></script>
<script type="text/javascript" src="../js/order.js"></script>
<script type="text/javascript" src="../js/alertMsg.js"></script>
<script>
    $(function() {
        var id = localStorage.getItem('orderShowId');
        var userInfo = JSON.parse(localStorage.getItem('userInfo'));
        var app_access = userInfo.app_access;
        var token = userInfo.token;
        var orderShow = {
            getOrderDetail: function() {
                var data = {
                    id: pageId,
                    app_access: app_access,
                    token: token
                }
                $.ajax({
                    url: '/api/order/bale/detail',
                    data: data,
                    type: 'post',
                    dataType: 'json',
                    success: function(res) {
                        if (res.code === 0) {
                            var data = res.data;
                            $('.name').html(data.name);
                            //    $('.level').html(data.level);

                             if(data.is_rob==1){
                                 $('.bond').html('¥'+data.bond+'元');
                             }else{
                                 $('.bondli').hide();
                                 $('.order_isrob').show();
                             }

                            $('.detail').html(data.detail);
                            if (data.styleNo !== '' && data.styleNo !== null) {
                                $('.styleNo').html(data.styleNo);
                            } else {
                                $('.styleNo').parent('li').remove();
                            }
                            if (data.grapCount !== '' && data.grapCount !== null) {
                                $('.grapcount').html(data.grapCount);
                            }
                            if (data.styleName !== '' && data.styleName !== null) {
                                $('.styleName').html(data.styleName);
                            } else {
                                $('.styleName').parent('li').remove();
                            }

                            if (data.money !== '' && data.money !== null) {
                                $('.money').html(data.money);
                            } else {
                                $('.money').parent('li').remove();
                            }

                            if (data.scence !== '' && data.scence !== null) {
                                $('.scence').html(data.scence);
                            } else {
                                $('.scence').parent('li').remove();
                            }

                            if (data.material !== '' && data.material !== null) {
                                $('.material').html(data.material);
                            } else {
                                $('.material').parent('li').remove();
                            }

                            if (data.tech !== '' && data.tech !== null) {
                                $('.tech').html(data.tech);
                            } else {
                                $('.tech').parent('li').remove();
                            }

                            if (data.num !== '' && data.num !== null) {
                                $('.num').html(data.num);
                            } else {
                                $('.num').parent('li').remove();
                            }

                            if (data.money !== '' && data.money !== null) {
                                $('.money').html(data.money);
                            } else {
                                $('.money').parent('li').remove();
                            }

                            if (data.proType !== '' && data.proType !== null) {
                                $('.proType').html(data.proType);
                            } else {
                                $('.proType').parent('li').remove();
                            }

                            if (data.region !== '' && data.region !== null) {
                                $('.region').html(data.region);
                            } else {
                                $('.region').parent('li').remove();
                            }

                            if (data.proWay !== '' && data.proWay !== null) {
                                $('.proWay').html(data.proWay);
                            } else {
                                $('.proWay').parent('li').remove();
                            }

                            if (data.cost !== '' && data.cost !== null) {
                                $('.cost').html(data.cost);
                            } else {
                                $('.cost').parent('li').remove();
                            }

                            if (data.style !== '' && data.style !== null) {
                                $('.style').html(data.style);
                            } else {
                                $('.style').parent('li').remove();
                            }

                            if (data.design !== '' && data.design !== null) {
                                $('.design').html(data.design);
                            } else {
                                $('.design').parent('li').remove();
                            }

                            if (data.period !== '' && data.period !== null) {
                                $('.period').html(data.period);
                            } else {
                                $('.period').parent('li').remove();
                            }


                            $('.status').text(data.status);

                            // 颜色
                            if (data.color.length !== 0) {
                                var colorHtml = ''
                                for (var i = 0; i < data.color.length; i++) {
                                    colorHtml += '<span>'+data.color[i]+'</span>'
                                }
                                $('.color').html(colorHtml)
                            } else {
                                $('.period').parent('li').remove();
                            }

                            // 大图片
                            if (data.img != '') {
                                $('.bigImg').html('<img src='+data.img+'>')
                            } else {
                                $('.bigImg').html('<img src="../../uploads/20190227/orderShowBig.png">')
                            }

                            // 小图片

                          //  var imgObj = JSON.parse(data.imgDetails)
                            if (data.imgDetails.length != 0) {
                                var smallHtml='';
                                /*
                                if(imgObj.a){
                                    smallHtml += '<li><img src='+MC.pImg(imgObj.a[0])+'></li>';
                                }
                                if(imgObj.b){
                                    smallHtml += '<li><img src='+MC.pImg(imgObj.b[0])+'></li>';
                                }
                                if(imgObj.c){
                                    smallHtml += '<li><img src='+MC.pImg(imgObj.c[0])+'></li>';
                                }*/
                                for(var i=0;i<data.imgDetails.length&&i<3;i++){
                                    smallHtml += '<li><img src='+MC.pImg(data.imgDetails[i])+'></li>';
                                }

                                $('.smallImg ul').html(smallHtml)
                            } else {
                                $('.smallImg ul').html(
                                    ''
                                )
                            }
                            
                            if(data.ismy){
                                $('#orderJingxuan').show();
                            }else{
                                $('#orderShowApply').show();                                
                            }

                            setTimeout(function () {
                                imgEnlargeFun ()
                            }, 500)

                        } else {
                            alertMsg(res.msg);
                        }
                    },
                    error: function(err) {
                        alertMsg(err)
                    }
                })
            }
        }
        $('#orderShowApply').click(function() {
            window.open('/h5/order/orderParam.html?id='+pageId,'_self');
           /* MC.click(function(){
                MC.api('GeneratePayOrder',{
                    bale:pageId
                },function(json){ 
                    window.open('/h5/order/orderParam.html?out_trade_no='+json.out_trade_no+'&id='+pageId,'_self');
                }); 

            });*/
        });
        $('#orderJingxuan').click(function() {
             window.open('/h5/order/orderXuanze.html?bale='+pageId,'_self');
        });
       
        orderShow.getOrderDetail()

        function imgEnlargeFun () { // 图片放大
            $('.smallImg li img').on('click', function () {
                var imgUrl = $(this).attr('src')
                $('.bigImg').children('img').attr('src', imgUrl)
            })
        }
    })
</script>

</html>